from pattern.circuit import Control

class entry(Control):
    
    def incoming(self, event):
        root, = event.data
        self.walk(event, root)
        
    def walk(self, event, root):
        self.visit(event, "pre", root)
        for child in root.childNodes():
            self.walk(event, child)
        self.visit(event, "post", root)
        
    def visit(self, event, temporal, root):
        bridge = self.acquireInterface(event, "visitor")
        if bridge is not None:
            bridge.push(temporal, root)
